{* $Id$ *}
{include_core file="admin/lib/header.html" title="用户展示"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">用户管理<span>{if $info.id}编辑{else}添加{/if}{$role}</span></h2>
    <a href="{AnUrl('user/admin')}" class="btn btn-default btn-sm right">&lt;&nbsp;返回用户列表</a>
</div>
<!--start:用户新增-->
<div class="add-form">
    <form class="js_creatform" action="{anurl('user/admin/area_manager/save')}" method="post" enctype="multipart/form-data">
        <table class="table" cellpadding="0" cellspacing="0">
            <input type="hidden" name="info[role_id]" value="{$role_id}"/>
            <input type="hidden" name="id" value="{$info.id}"/>
            <tr>
                <th><label for="" class="add-f-label">选择总监：</label></th>
                <td>
                    <select id="director" name="info[director_id]">
                        <option value="0">请选择总监</option>
                        {html_options options=$director_list selected=$info.director_id}
                    </select>
                </td>
            </tr>
            <tr>
                <th><label for="" class="add-f-label">管理区域：</label></th>
                <td>
                    {foreach $area as $k => $v}
                    {if ((($k+1) % 5) == 1)}<p style="line-height: 30px;">{/if}
                    <label><input type="checkbox" value="{$v['area_code']}" name="area[]" {if in_array($v['area_code'] ,$user_area)}checked="checked"{/if}> {$v['area']}</label> &nbsp;&nbsp;
                    {if ((($k+1) % 5) == 0)}</p>{/if}
                    {/foreach}
                </td>
            </tr>
            {include file="admin/add_common_field.html"}
        </table>
    </form>
</div>
<!--end:用户新增-->
{include_core file="admin/lib/footer.html"}
<script>
    $(function () {
        // 提交验证
        $('.js_submit').click(function (e) {

            e.preventDefault();
            var director = $('#director').val();
            var userName = $.trim($('input[name="info[user_name]"]').val());
            var password = $.trim($('input[name="info[password]"]').val());
//            var email = $.trim($('.js_email').val());
            var mobile = $.trim($('.js_mobile').val());
//            var nickname = $.trim($('input[name="info[nickname]"]'));
            var realname      = $.trim($('input[name="info[realname]"]').val());

            if (director == 0) {
                showMsg('请先选择总监!');
                return false;
            }

            // 真实姓名不能为空
            if (realname == '') {
                showMsg('真实姓名不能为空!');
                return false;
            }
            // 登录名不能为空
            if (userName == '') {
                showMsg('真实姓名不能为空!');
                return false;
            }

            // 真实姓名不能为空
//            if ($('input[name="info[nickname]"]').val() == '') {
//                showMsg('昵称不能为空!');
//                return false;
//            }

            if (password && is_pwd_null(password)) {
                showMsg('密码内不能存在空字符!');
                return;
            }
            if (password && getStringLen(password) < 6) {
                showMsg('密码不能少于6个字符!');
                return;
            }

//            if (email) {
//                if (!checkStr(email, 'mail')) {
//                    showMsg('邮箱格式不正确!');
//                    return;
//                }
//            }
            if (mobile) {
                if (!checkStr(mobile, 'mobile')) {
                    showMsg('手机号码格式不正确!');
                    return;
                }
            }

            $('.js_creatform').submit();
        });
        /*
         //上传图片预览
         $(".js_upFile").each(function(i){
         $(this).change(function(e){
         handleFileSelect($(this), 270);
         });
         }); */
    });
</script>